package com.mytecblog.article.entity;

import com.mytecblog.framework.entity.MetaObject;
import org.hibernate.annotations.Type;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;

/**
 * @author yg.huang
 * @version v1.0
 *          DATE  2016/10/31
 */
@Entity
@Table(name = "cms_article")
public class Article extends MetaObject {

    /**
     * 作者
     */
    private long author;
    /**
     * 文章标题
     */
    private String title;
    /**
     * 文章内容
     */
    private String content;
    /**
     * 文章分类id
     */
    private Long category;

    /**
     * 文章摘要
     */
    private String excerpt;
    /**
     * 父级文章
     */
    private Long parent;
    /**
     * 文章状态
     */
    private Integer status;





    @Basic
    @Column(name = "author", nullable = true)
    public long getAuthor() {
        return author;
    }

    public void setAuthor(long author) {
        this.author = author;
    }

    @Basic
    @Column(name = "title", nullable = true, length = 300)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Basic
    @Type(type = "text")
    @Column(name = "content", nullable = true, length = 20000)
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Basic
    @Column(name = "category", nullable = true)
    public Long getCategory() {
        return category;
    }

    public void setCategory(Long category) {
        this.category = category;
    }

    @Basic
    @Type(type = "text")
    @Column(name = "excerpt", nullable = true, length = 20000)
    public String getExcerpt() {
        return excerpt;
    }

    public void setExcerpt(String excerpt) {
        this.excerpt = excerpt;
    }

    @Basic
    @Column(name = "parent", nullable = true)
    public Long getParent() {
        return parent;
    }

    public void setParent(Long parent) {
        this.parent = parent;
    }

    @Basic
    @Column(name = "status", nullable = true)
    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }






    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Article article = (Article) o;

        if (id != article.id) return false;
        if (author != article.author) return false;
        if (title != null ? !title.equals(article.title) : article.title != null) return false;
        if (content != null ? !content.equals(article.content) : article.content != null) return false;
        if (category != null ? !category.equals(article.category) : article.category != null) return false;
        if (excerpt != null ? !excerpt.equals(article.excerpt) : article.excerpt != null) return false;
        if (parent != null ? !parent.equals(article.parent) : article.parent != null) return false;
        if (status != null ? !status.equals(article.status) : article.status != null) return false;
        if (createTime != null ? !createTime.equals(article.createTime) : article.createTime != null) return false;
        if (updateTime != null ? !updateTime.equals(article.updateTime) : article.updateTime != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (id ^ (id >>> 32));
        result = 31 * result + (int) (author ^ (author >>> 32));
        result = 31 * result + (title != null ? title.hashCode() : 0);
        result = 31 * result + (content != null ? content.hashCode() : 0);
        result = 31 * result + (category != null ? category.hashCode() : 0);
        result = 31 * result + (excerpt != null ? excerpt.hashCode() : 0);
        result = 31 * result + (parent != null ? parent.hashCode() : 0);
        result = 31 * result + (status != null ? status.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
        return result;
    }
}
